package com.wmjsoft.proxyDemo

import java.lang.reflect.InvocationHandler
import java.lang.reflect.Proxy

fun main() {
    val u:UserServiceInterface = UserService()
    val handler:InvocationHandler = InvocationHandlerImpl(u)
    val loader = u::class.java.classLoader
    val interfaces = u::class.java.interfaces

    val u1 = Proxy.newProxyInstance(loader,interfaces,handler) as UserServiceInterface
//    if(u1 is UserServiceInterface){
        u1.test("sss")
//    }

    println("动态代理对象的类型：${u::class.java.name}")
}